extends layout2

block content	
	link(rel='stylesheet', href='https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.37/css/bootstrap-datetimepicker.min.css')
	script(src='https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.6/moment.min.js')		
	script(src='https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.37/js/bootstrap-datetimepicker.min.js')
	script.
		$(function(){
			var dateNow = new Date();
			$("#datetimepicker2").datetimepicker({
				defaultDate:moment(dateNow),				
				format: 'YYYY-MM-DD HH:mm'
			});

			$("input[name=update_time]").val("");
		});
	include header	
	.container-fluid
		.row
			include menu			
			.col-sm-9.col-sm-offset-3.col-md-10.col-md-offset-2.main				
				.row.placeholders					
				h2.sub-header 固件
				div
					-if(uclass=="1")
						button.btn.btn-default(data-target='#layerpop', data-toggle='modal') File upload
					-else
					
					br
					#layerpop.modal.fade
						.modal-dialog
							.modal-content
								// header
								.modal-header
									// 닫기(x) 버튼
									button.close(type='button', data-dismiss='modal') ×
									// header title
									h4.modal-title 上传文件
								// body
								.modal-body
								form(method='POST', action='upload' , enctype="multipart/form-data" onsubmit="return upFormCheck()")										
									h5.text-center 只能在指定路径上传文件.
										table#tblGrid.table.table-striped
											tbody(align="left")
												tr
													th 文件选择
													td
														input(type="file",name='upfile' id="upfile")
												tr
													th 更新类型
													td
														input(type="radio", name="update_type" value="개별적")
														| 个人
														input(type="radio", name="update_type" value="일괄적")
														| 集体														
												tr
													th 更新节点类型
													td
														div#collective(style="display:none;")
															select(style="width:100%;" name="update_node_type")
																option 选择节点类型
																option(value="温度传感器") 温度传感器
																option(value="湿度传感器") 湿度传感器
																option(value="二氧化碳传感器") 二氧化碳传感器
																option(value="加速度计") 加速度计
														div#singly
															select(style="width:70%;" name="gateway_sel")
																option 选择您的网关
															select(style="width:28%;" name="node_sel")
																option 节点选择
												tr
													th 更新节点列表
													td
														div#node-list
															input(type="hidden" name="gateway_address" id="g_address")
															select(multiple="multiple" name="update_node_list[]" style="width:100%;")
												tr
													th 更新日期
													td
														div#datetimepicker2.input-group.date
															input.form-control(type='text' name='update_time')
															span.input-group-addon
																span.glyphicon.glyphicon-calendar				
												tr
													td(colspan="2" style="text-align:center;")
														button(type="submit") 업로드
								div(style="clear:both;")
				.table-responsive(style="clear:both;")
					table.table.table-striped
						thead
							tr
								th Filename
								th Size
								th Date
								th
						tbody
							form(method='POST', action='/download/fileDown' , name='downloadForm')
								input(type='hidden',name='path' , id='fileValue')
							-if(totalfile.length==0)
								tr
									td(colspan="4")
										a(href="/firmware")
											span.glyphicon.glyphicon-folder-open &nbsp;	
							-else
								-for(var i in totalfile)
									tr
										-if(totalfile[i].filetype=='directory')
											td
												a(href="javascript:alert('文件夹移动受限.')")
													span.glyphicon.glyphicon-folder-open &nbsp;#{totalfile[i].filename}											
										-else
											td 
												a(href="javascript:downloadAsPost('#{filepath}/#{totalfile[i].filename}');") #{totalfile[i].filename}
											td= totalfile[i].size
											td= totalfile[i].birthtime
											td															
												-if(uclass=="1")
													-if(!(totalfile[i].filename.split(".")[1]=="xml" || totalfile[i].filename.split(".")[1]=="json"))
														button.btn.btn-primary(type='button' onclick="createMOandDD('#{totalfile[i].filename}','#{totalfile[i].birthtime}')") MO,DD 생성(json)													
														button.btn.btn-primary(type='button' onclick="createMOandDD2('#{totalfile[i].filename}','#{totalfile[i].birthtime}')") MO,DD 생성(xml)
													button.btn.btn-danger(type='button' onclick="deleteProc('#{totalfile[i].filename}')") 삭제